import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tiktokadult/assets_tool/images.dart';
import 'package:tiktokadult/hj_model/video_model.dart';
import 'package:tiktokadult/hj_page/find/pic_collect/pics_detail_page.dart';
import 'package:tiktokadult/hj_utils/widget_utils.dart';
import 'package:tiktokadult/tools_base/widget/net_image_widget.dart';

class SearchTujiCell extends StatelessWidget {
  final VideoModel? videoModel;
  final Function? callback;
  final int textline;

  SearchTujiCell({
    this.videoModel,
    this.callback,
    this.textline = 1,
  });

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        if (callback != null) {
          callback?.call();
        } else {
          Get.to(
              PicsDetailPage(
                id: videoModel?.id,
              ),
              preventDuplicates: false);
        }
      },
      child: Column(
        children: [
          Expanded(
            child: Stack(
              fit: StackFit.expand,
              children: [
                NetworkImageLoader(
                  imageUrl: videoModel?.cover ?? "",
                  compress: true, //图集尺寸太大，减少内存吃紧的情况
                ),
                Positioned(
                  bottom: 0,
                  left: 0,
                  right: 0,
                  child: Container(
                    decoration: BoxDecoration(
                        gradient: LinearGradient(
                      colors: [
                        Colors.black.withOpacity(0),
                        Colors.black.withOpacity(.6),
                      ],
                      begin: Alignment.topCenter,
                      end: Alignment.bottomCenter,
                    )),
                    height: 30,
                    child: Row(
                      children: [
                        8.sizeBoxW,
                        Image.asset(
                          "count_eye.png".communityPath,
                          width: 16,
                          height: 16,
                        ),
                        SizedBox(width: 2),
                        Text(
                          videoModel?.playCount?.humanizeFormat ?? "",
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 10,
                          ),
                        ),
                        Spacer(),
                        Image.asset(
                          "tuji_icon.webp".communityPath,
                          width: 16,
                        ),
                        2.sizeBoxW,
                        Text(
                          '${videoModel?.seriesCover?.length ?? 0}',
                          textAlign: TextAlign.justify,
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 10,
                          ),
                        ),
                        8.sizeBoxW,
                      ],
                    ),
                  ),
                )
              ],
            ),
          ),
          4.sizeBoxH,
          Row(
            children: [
              Expanded(
                child: Text(
                  '${videoModel?.title}',
                  maxLines: textline,
                  overflow: TextOverflow.ellipsis,
                  style: TextStyle(
                    color: Colors.white.withOpacity(.9),
                    fontSize: 12,
                  ),
                ),
              )
            ],
          )
        ],
      ),
    );
  }
}
